using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pub_Module_Ads : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        BindData();

    }

    private void BindData()
    {
        try
        {

            // ds.ReadXml(Server.MapPath("~/Database/XML/Ads.xml"));
            clsWebShop cls = new clsWebShop();
            DataSet ds = new DataSet();
            ds = cls.GetData("select * from Ads  Where KindNo='A' and Status<>'D' order by UpdDate Desc");
            dtlHeaderIcon.DataSource = ds;
            dtlHeaderIcon.DataBind();
        }
        catch (Exception ex) { };


    }
    protected void dtlHeaderIcon_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            if (DataBinder.Eval(e.Item.DataItem, "AdsType").ToString().ToUpper() == "IMG")
            {
                HtmlAnchor embed = new HtmlAnchor();
                embed.InnerHtml = " <a target='_blank' href='" + DataBinder.Eval(e.Item.DataItem, "AdsLink").ToString() + "'> <img border='0' src='" + ResolveUrl("~/" + DataBinder.Eval(e.Item.DataItem, "AdsURL")) + "' width='172px'></a>";
                e.Item.Controls.Add(embed);
            }
            else if (DataBinder.Eval(e.Item.DataItem, "AdsType").ToString().ToUpper() == "SWF")
            {
                HtmlAnchor embed = new HtmlAnchor();
                embed.InnerHtml = "<a  target='_blank' href='" + DataBinder.Eval(e.Item.DataItem, "AdsLink").ToString() + "'><embed quality='high'   src='" + ResolveUrl("~/" + DataBinder.Eval(e.Item.DataItem, "AdsURL")) + "'  loop='false' width='172px' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> </embed> </a>";
                e.Item.Controls.Add(embed);
            }
        }
    }
}
